# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=inkscape
pkgver=1.0
pkgrel=3
pkgdesc="A vector-based drawing program - svg compliant"
url="https://inkscape.org/"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="
	boost-dev
	cmake
	dbus-dev
	double-conversion-dev
	gc-dev
	gdl-dev
	gsl-dev
	gtkmm3-dev
	gtkspell3-dev
	gzip
	imagemagick6-dev
	lcms-dev
	libcdr-dev
	libjpeg-turbo-dev
	libsoup-dev
	libtool
	libvisio-dev
	libxml2-dev
	libxslt-dev
	poppler-dev
	popt-dev
	potrace-dev
	python3-dev
	ttf-dejavu
	tar
	"
depends="desktop-file-utils"
checkdepends="bash py3-lxml py3-numpy>=1.14.3-r1"
subpackages="$pkgname-doc $pkgname-lang $pkgname-view"
source="https://media.inkscape.org/dl/resources/file/inkscape-$pkgver.tar.xz
	fix-Werror.patch
	"
options="!check" # cxxtest hangs at least on x86_64
builddir="$srcdir"/inkscape-1.0_2020-05-01_4035a4fb49

build() {
	export CXXFLAGS="$CXXFLAGS -std=c++11"
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_STATIC_LIBS=False \
		-DBUILD_TESTS=ON \
		-DWITH_GNOME_VFS=OFF \
		$CMAKE_CROSSOPTS .
	make -j1 -C build
}

check() {
	PATH="$PATH:$PWD" make -C src check
}

package() {
	DESTDIR="$pkgdir" make -C build install
}

view() {
	pkgdesc="Viewing program for SVG files"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/inkview "$subpkgdir"/usr/bin
}

doc() {
	default_doc
	mkdir -p "$subpkgdir"/usr/share/inkscape
	mv "$pkgdir"/usr/share/inkscape/examples \
		"$pkgdir"/usr/share/inkscape/tutorials \
		"$subpkgdir"/usr/share/inkscape
}

sha512sums="37c18079eb926fd6874deee95e4008bae165c5e52d05cb53bbc8f4a48eedd0e0ab6b3e5dfbb23709169187bfe8eb5aa44d576268667f2566a2cd4dd5426554f0  inkscape-1.0.tar.xz
af18732affeebf3f3b686d88e06f2637b320570095fdcf330ce078243910f43edbd99145ff370da6ec29dc9239948e83f46b2e2b6ca0ce851356912e6bc0fa2d  fix-Werror.patch"
